/**
 * Copyright (c) 2010-2011 julewa.com.  
 * All rights reserved. 
 * 
 * @author Huang Benhua
 * @date 2011-2-20
 * 
**/
package com.julewa.db;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.List;
import java.util.Map;

@SuppressWarnings("rawtypes")
public interface DB {
	public static final int TEXT_LENGTH_DEFAULT = 128;
	@Retention(RetentionPolicy.RUNTIME)
	@Target({ElementType.FIELD, ElementType.METHOD})
	public @interface COLUMN{
		public double min() default Double.MIN_VALUE;
		public double max() default Double.MAX_VALUE; 
		public boolean nullable() default true;
	};
	@Retention(RetentionPolicy.RUNTIME)
	@Target({ElementType.FIELD, ElementType.METHOD})
	public @interface KEY{
		public double min() default Double.MIN_VALUE;
		public double max() default Double.MAX_VALUE; 
	};
	@Retention(RetentionPolicy.RUNTIME)
	@Target({ElementType.FIELD, ElementType.METHOD})
	public @interface SEARCH {
		public boolean parse() default true;
		public boolean store() default true; 
	}
	@Retention(RetentionPolicy.RUNTIME)
	@Target({ElementType.FIELD})
	public @interface DEPENDON {
		public String[] value() default {};
	}
	@Retention(RetentionPolicy.RUNTIME)
	@Target({ElementType.FIELD, ElementType.METHOD})
	public @interface AUTOTRIM {
		public boolean prefix() default true;
		public boolean any() default false;
		public boolean suffix() default true; 
	}
	@Retention(RetentionPolicy.RUNTIME)
	@Target({ElementType.TYPE})
	public @interface USECACHE{};
	
	@Retention(RetentionPolicy.RUNTIME)
	@Target({ElementType.TYPE})
	public @interface DYNAMIC{
		public String suffix() default "_table_suffix_";
	};

  //
  public List getList(String id, Object param); 
  public List getList(String id, Object param, int skip, int max); 
  public Map getMap(String id, Object param, String key);
  
  //
  public Object getObject(String id, Object param);
  public Object getObject(String id, Object param, Object resultObject);
  
  //
  public void startBatch(); 
  public int executeBatch(); 
  
  //
  public boolean insert(String id, Object param);
  public boolean update(String id, Object param);
  public boolean delete(String id, Object param);
  
  //
  public <T> T create(Class<T> clazz);
  public Object create(String type);
  public BeanInfo getBeanInfo(String type);
  public BeanInfo getBeanInfo(Class<?> type);
  public String findColumnLabel(String column);
  public String findColumnLabel(String prefix, String column);
}